<h1><?php echo $collection_item->getCollectionName() ?></h1>
<div id="collection-details">
    <h2>Details</h2>
    <?php include_partial('collectionItemListing', array('collectionItem' => $collection_item)) ?>
    <?php $systemRelations = $collection_item->getRelationsByIdentifierArray(sfConfig::get('app_view_subdomain_relation_types')); ?>
    <?php if ($systemRelations->count() > 0): ?>
        <h2>Sub-Domains</h2>
        <ul class="related-collection-item-list">

        <?php foreach ($systemRelations as $systemRelation): ?>
            <li>
                <a href="<?php echo url_for('domainViewDetails', array('uin' => $systemRelation->getRelatedItem()->getUin())) ?>"><?php echo $systemRelation->getRelatedItem()->getCollectionName() ?></a>
            <?php include_partial('collectionItemListing', array('collectionItem' => $systemRelation->getRelatedItem())) ?>
        </li>
        <?php endforeach; ?>
        </ul>
    <?php endif; ?>
            <h2>Systems</h2>

    <?php $systemRelations = $collection_item->getRelationsByIdentifierArray(sfConfig::get('app_domains_planned_system_relation_types')); ?>
    <?php if ($systemRelations->count() > 0): ?>
                <h3>Planned Systems</h3>
                <ul class="related-collection-item-list">
        <?php foreach ($systemRelations as $systemRelation): ?>
                    <li>
                        <a href="<?php echo url_for('domainViewDetails', array('uin' => $systemRelation->getRelatedItem()->getUin())) ?>"><?php echo $systemRelation->getRelationType()->getTypeName() ?>, <?php echo $systemRelation->getRelatedItem()->getCollectionName() ?></a>
            <?php include_partial('collectionItemListing', array('collectionItem' => $systemRelation->getRelatedItem())) ?>
                </li>
        <?php endforeach; ?>
                </ul>
    <?php endif; ?>

    <?php $systemRelations = $collection_item->getRelationsByIdentifierArray(sfConfig::get('app_domains_authoritative_system_relation_types')); ?>
    <?php if ($systemRelations->count() > 0): ?>
                        <h3>Authoritative Systems</h3>
                        <ul class="related-collection-item-list">
        <?php foreach ($systemRelations as $systemRelation): ?>
                            <li>
                                <a href="<?php echo url_for('domainViewDetails', array('uin' => $systemRelation->getRelatedItem()->getUin())) ?>"><?php echo $systemRelation->getRelationType()->getTypeName() ?>, <?php echo $systemRelation->getRelatedItem()->getCollectionName() ?></a>
            <?php include_partial('collectionItemListing', array('collectionItem' => $systemRelation->getRelatedItem())) ?>
                        </li>
        <?php endforeach; ?>
                        </ul>
    <?php endif; ?>

    <?php $nonAuthRelations = array_diff(sfConfig::get('app_domains_current_system_relation_types'), sfConfig::get('app_domains_authoritative_system_relation_types')) ?>
    <?php $systemRelations = $collection_item->getRelationsByIdentifierArray($nonAuthRelations); ?>
    <?php if ($systemRelations->count() > 0): ?>
                                <h3>Non-Authoritative Systems</h3>
                                <ul class="related-collection-item-list">

        <?php foreach ($systemRelations as $systemRelation): ?>
                                    <li>
                                        <a href="<?php echo url_for('domainViewDetails', array('uin' => $systemRelation->getRelatedItem()->getUin())) ?>"><?php echo $systemRelation->getRelationType()->getTypeName() ?>, <?php echo $systemRelation->getRelatedItem()->getCollectionName() ?></a>
            <?php include_partial('collectionItemListing', array('collectionItem' => $systemRelation->getRelatedItem())) ?>
                                </li>
        <?php endforeach; ?>
                                </ul>
    <?php endif; ?>

    <?php $systemRelations = $collection_item->getRelationsByIdentifierArray(sfConfig::get('app_domains_current_system_relation_types'), true); ?>
    <?php if ($systemRelations->count() > 0): ?>
                                        <h2>Serviced Information Domains</h2>
                                        <ul class="related-collection-item-list">
        <?php foreach ($systemRelations as $systemRelation): ?>
                                            <li>
                                                <a href="<?php echo url_for('domainViewDetails', array('uin' => $systemRelation->getThisItem()->getUin())) ?>"><?php echo $systemRelation->getThisItem()->getCollectionName() ?></a>
            <?php include_partial('collectionItemListing', array('collectionItem' => $systemRelation->getThisItem())) ?>
                                        </li>
        <?php endforeach; ?>
                                        </ul>
    <?php endif; ?>
                                            <h2>More Information</h2>
                                            <p>
                                                More information on this record may be available from the central repository, <a href="<?php echo ('HTTP://' . $_SERVER['HTTP_HOST'] . '/' . (sfApplicationConfiguration::getActive()->getEnvironment() != 'prod' ? 'frontend_' . sfApplicationConfiguration::getActive()->getEnvironment() . '.php' : '') . '/collection/' . $collection_item->getUin() ) ?>">click here to view the original record</a>.
    </p>
</div>

